/*
 *  SBJ/NXT/CommandStatus.cpp
 *  NXTFace
 *
 *  Created by David Giovannini on 8/23/06.
 *  Copyright 2006 Software by Jove. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */
 
#include "SBJ/NXT/CommandStatus.h"

namespace SBJ
{

namespace NXT
{
	
CommandStatus::CommandStatus( void )
: m_status( good )
{
}

CommandStatus::CommandStatus( unsigned char status )
: m_status( status )
{
}

CommandStatus::CommandStatus( const CommandStatus& rhs )
: m_status( rhs.m_status )
{
}

bool
CommandStatus::isFatal( void ) const
{
	switch ( m_status )
	{
		case connection_invalid:
			return true;
		default:
			break;
	}
	return false;
}

const std::string
CommandStatus::message( void ) const
{
	switch ( m_status )
	{
		case good:
			return "";
		case pending_transaction:
			return "Pending communication transaction in progress";
		case mailbox_empty:
			return "Specified mailbox queue is empty";
		case request_failed:
			return "Request failed (i.e. specified file not found)";
		case unknown_command:
			return "";
		case insane_packet:
			return "Insane packet";
		case out_of_range:
			return "Data contains out-of-range values";
		case comm_bus_err:
			return "Communication bus error";
		case comm_no_mem:
			return "No free memory in communication buffer";
		case connection_invalid:
			return "Specified channel/connection is not valid";
		case connection_busy:
			return "Specified channel/connection not configured or busy";
		case program_not_running:
			return "No active program";
		case illegal_size:
			return "Illegal size specified";
		case illegal_mail_id:
			return "Illegal mailbox queue ID specified";
		case inavlid_field_access:
			return "Attempted to access invalid field of a structure";
		case bad_io:
			return "Bad input or output specified";
		case no_mem:
			return "Insufficient memory available";
		case bad_args:
			return "Bad arguments";
		default:
			break;
	}
	return "unknown status";
}

}

}
